#include "mainwindow.h"
#include "qwt_plot_panner.h"
#include "qwt_plot_zoomer.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
  ui->setupUi(this);
  m_plot = new QwtPlot(this);
  this->setCentralWidget(m_plot);
  m_canvas = new QwtPlotOpenGLCanvas(m_plot);
  m_plot->setCanvas(m_canvas);
  m_grid = new QwtPlotGrid;
  m_grid->attach(m_plot);
  m_grid->setPen(QColor(Qt::red));

  // auto zoomer = new QwtPlotZoomer(m_canvas);
  // zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
  //                         Qt::ControlModifier);
  // zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
  // zoomer->setRubberBandPen(QPen(QColor(Qt::white)));

  m_curve = new QwtPlotCurve("Data Test");
  m_curve->setPen(Qt::green);
  m_curve->setRenderHint(QwtPlotCurve::RenderAntialiased);
  m_curve->setSamples(
      {QPointF(0, 0), QPointF(2, 5), QPoint(3, 9), QPointF(9, 13)});
  m_curve->attach(m_plot);

  auto m_panner = new QwtPlotPannerPlus(m_canvas);
}

MainWindow::~MainWindow() { delete ui; }
